package utils;

//TO DO
//DO i have to create new positions or just use old ones?
public class PositionMath {
    public Position addPositions(Position first, Position second){
        double poz_x = first.getX() + second.getX();
        double poz_y = first.getY() + second.getY();

        return new Position(poz_x,poz_y);
    }

    public void addPositionsImplicitly(Position first, Position second){
        double poz_x = first.getX() + second.getX();
        double poz_y = first.getY() + second.getY();

        setResults(first,poz_x,poz_y);
    }

    public Position subPositions(Position first, Position second){
        double poz_x = first.getX() - second.getX();
        double poz_y = first.getY() - second.getY();

        return new Position(poz_x,poz_y);
    }

    public Position multiplyPositionByScalar(Position position, double scalar){
        double poz_x = position.getX() * scalar;
        double poz_y = position.getY() * scalar;

        return new Position(poz_x,poz_y);
    }

    public void multiplyPositionImplicitly(Position position, double scalar){
        double poz_x = position.getX() * scalar;
        double poz_y = position.getY() * scalar;

        setResults(position,poz_x,poz_y);
    }

    public Position dividePositionByScalar(Position position, double scalar){
        double poz_x = position.getX() / scalar;
        double poz_y = position.getY() / scalar;

        return new Position(poz_x,poz_y);
    }

    public double determineDistance(Position first, Position second){
        double poz_x = first.getX() - second.getX();
        double poz_y = first.getY() - second.getY();
        return Math.sqrt(poz_x * poz_x  + poz_y * poz_y);
    }

    private void setResults(Position toSet, double x, double y){
        toSet.setX(x);
        toSet.setY(y);
    }
}
